﻿Imports DATA
Imports SERVICIOS

Public Class oFm_listaAsistencia

    Dim WithEvents oAsistencia As New asistencia_data
    Dim oFun As New funcionario_data

    Private Sub oFm_listaAsistencia_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Me.Dispose()
    End Sub

    Private Sub oFm_listaAsistencia_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.TituloFormulario = "Listado de asistencias"
        CrearGrilla()
        CargarAsistencia()
    End Sub

    Sub CrearGrilla()
        With oGr_datos
            .Columns.Clear()
            .MaquillaGrilla()
            .SelectionMode = DataGridViewSelectionMode.CellSelect
            .ReadOnly = True
            'agregando columnas de normal y de días 
            .Columns.Add("", "Fecha")
            .Columns.Add("", "Grupo")
            'Ancho de columnas
            .ColWidth(0) = 180
            'Color de una columna
            .Columns(0).DefaultCellStyle.BackColor = Color.Aqua
        End With

    End Sub

    Sub CargarAsistencia()
        With oGr_datos
            .Rows.Clear()
            Dim dt As DataTable = oAsistencia.GetData
            Try
                .Rows_P = dt.Rows.Count
                Dim i As Integer = 0
                For Each x In dt.Rows
                    .TextMatrix(i, 0) = x.item(0)
                    .TextMatrix(i, 1) = x.item(1)
                    i += 1
                Next
            Catch ex As Exception

            End Try
        End With
    End Sub

    Private Sub oPb_Salir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles oPb_Salir.Click
        Me.Close()
    End Sub

    Private Sub oPb_guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles oPb_guardar.Click
        oFm_AgregarColumnas.ShowDialog()
        CargarAsistencia()
    End Sub

    Private Sub oGr_datos_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles oGr_datos.CellDoubleClick
        With oGr_datos
            oFm_asistencia._eTipo = oFm_asistencia.eTipo.EditarRegistros
            oFm_asistencia._Fecha = CDate(.TextMatrix(.Row, 0))
            oFm_asistencia._grupoId = oFun.msoIdGrupoxNombre(Trim(.TextMatrix(.Row, 1)))
            oFm_asistencia._grupoNombre = Trim(.TextMatrix(.Row, 1))
            oFm_asistencia.ShowDialog()
        End With
    End Sub


End Class
